//
//  DatePackerUtil.m
//  FreeTime
//
//  Created by  on 16/8/27.
//  Copyright © 2016年 SRDZ.com. All rights reserved.
//

#import "DatePackerUtil.h"
#import "Header.h"

@interface DatePackerUtil (){
    dateCallback  myBlock;
    UIDatePicker * datePicker ;
}

@end

@implementation DatePackerUtil

- (void)creatDatePack:(UIViewController*)control dateBlock:(dateCallback)dateBlock{
    UIView * bgView = [[UIView alloc] initWithFrame:CGRectMake(0, WindowHeight-264, WindowWidth, 200)];
    bgView.backgroundColor = [UIColor purpleColor];
    datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, WindowWidth, 150)];
    myBlock = dateBlock;
    
    datePicker.datePickerMode = UIDatePickerModeDate;
//    NSDate * maxDate = [[NSDate alloc] initWithTimeIntervalSince1970:[@"1244442" doubleValue]];
    datePicker.backgroundColor = [UIColor yellowColor];
    
    UIButton * btn = [ReduceCode creatBtnWithFrame:CGRectMake(WindowWidth-70, 160, 60, 30) btnTitle:@"确定" btnTitleColor:[UIColor blueColor] btnTitleFont:13 btnBackgroundColor:[UIColor redColor] backgroundImage:nil isCorner:NO];
    [btn addTarget:self action:@selector(enter) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:datePicker];
    [bgView addSubview:btn];

    [control.view addSubview:bgView];
    
    
}
- (void)enter{
    myBlock(@{@"datePick":datePicker});
}

- (void)creatAlertView:(UIViewController *)control frame:(CGRect)Viewframe enterBlock:(enterCallback)enterBlock  cancleBlock:(enterCallback)cancleBlock{
    UIView * bgView = [[UIView alloc] initWithFrame:control.view.bounds];
    bgView.backgroundColor = [UIColor grayColor];
    bgView.alpha = 0.8;
    UIView * aView = [[UIView alloc] initWithFrame:CGRectMake(30, (WindowHeight-150-64-49)/2, WindowWidth-60, 150)];
    aView.layer.cornerRadius = 5;
    aView.backgroundColor = [UIColor whiteColor];
    NSArray * arr = @[@"提示",@"性别选择后将不可再修改"];
    NSArray * arr1 = @[@"确定",@"取消"];
    NSArray * arr2 = @[HOME_COLOR,[ImageUtil colorWithRgb:0x666666]];


    for (int i = 0; i<2;i++) {
        UILabel * alertLbl = [ReduceCode creatLabelWithFrame:CGRectMake(0, i*45, aView.frame.size.width, 45) title:arr[i] titleColor:[ImageUtil colorWithRgb:0x666666] font:18 textAlignment:1];
        UIButton * btn = [ReduceCode creatBtnWithFrame:CGRectMake(i*(aView.frame.size.width/2), 90, aView.frame.size.width/2, 50) btnTitle:arr1[i] btnTitleColor:arr2[i] btnTitleFont:14 btnBackgroundColor:[UIColor yellowColor] backgroundImage:nil isCorner:NO];
        [btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
        btn.tag = 100+i;
        [aView addSubview:btn];
        if (i==1) {
            alertLbl.font = FONT(14);
            [ToolUtil createLine:44 superView:alertLbl lift:15 width:alertLbl.frame.size.width-30 hight:1 color:[ImageUtil colorWithRgb:0xe6e6e6]];
            [ToolUtil createVerticalLine:10 superView:btn lift:0 height:30 color:[ImageUtil colorWithRgb:0xe6e6e6]];
        }
        
        [aView addSubview:alertLbl];
        
    }
    
    
    
    
    
    
    [bgView addSubview:aView];
    
    
    [control.view addSubview:bgView];
    
    
}
- (void)clickBtn:(UIButton *)btn{

    
}
@end
